//
//  HOBaseViewController.h
//  WeiDu_1_0
//
//  Created by foguo-mac-1 on 01/07/16.
//  Copyright (c) 2016 WeiDu Energy Tech. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "HOLoadingView.h"
#import "HODefine.h"
#import "HOViewControllerDelegate.h"
#import "HOControllerDelegate.h"
#import "HOAlertView.h"
#import "HOBaseDataModule.h"
#import "HOBaseController.h"
#import "HOSearchView.h"
#import "HOCustomButtn.h"
#import "HOEditTableViewCell.h"
#import "HOBaseResponseEntity.h"
#import "HOTableView.h"

@interface HOBaseViewController : UIViewController <HOViewControllerDelegate,
UIAlertViewDelegate,
UITableViewDataSource,
UITableViewDelegate,
UIActionSheetDelegate,
UIPickerViewDelegate,
UIGestureRecognizerDelegate,
UIPickerViewDataSource,
AMSearchViewDelegate,
UITextFieldDelegate>
{
    HOLoadingView                       *hintView;
    HOLoadingView                       *loadingView;
    CGSize                              keyboardSize;
    KEYBOARD_TYPE                       keyboardType;
    UINavigationItem                    *navigationBarItem;
	
    HO_MODULE_TYPE                      moduleType;
	HOBaseDataModule                    *dataModule;
	HOBaseController                    *controller;
	
	
	//Audio and Image
	UIImageView *bgRecordImg;
	UIView		*auditionView;
	AUDIO_PLAY_STATUS auditionStatus;
	NSInteger indicateImgIndex;
	UILabel 		*audioTotalTimeLbl;
	//--
	
    
    
    HOTableView                         *baseTableview;
	
	
    NSTimer                             *timeoutTimer;
    //picker view
    UIPickerView                        *pickerViewImp;
    UIView                              *pickerPanelView;
    NSInteger                           pickerViewSelectRow;
    
    //search view
    HOSearchView                        *searchView;
    UITapGestureRecognizer              *tapRecognizer;
    BOOL                                noNeedReleaseList;;
    BOOL                                isRequesting;
    UIButton *titleLabelButton;
    CGFloat                             tableViewY;
    BOOL                                keyboardPopupedBefore;
    NSMutableDictionary					*entityDic;
    BOOL                                isRegisterKeyboard;
    BOOL                                dontReleaseTableDataList;
	
}

//@property(nonatomic, retain)AMAlertView                         *amAlertView;

@property(nonatomic, retain)UIView                              *noResultView;
@property(nonatomic, retain)NSString							*phoneNumber;
@property (nonatomic, retain)NSString							*verifyCode;
@property(nonatomic, retain)UITextField							*phoneNumberTextField;
@property(nonatomic, retain)UITextField							*verifyCodeTextField;
@property(nonatomic, retain)NSString							*navTitle;
@property(nonatomic, assign)BOOL								isPaySuccess;
@property(nonatomic, retain)NSMutableArray                      *tableViewDataList;
//@property(nonatomic, assign)BOOL								isBelongLoginScreen;//标记当前screen是login,register,findpwd等页面
//@property(nonatomic,retain)NSMutableArray 						*dataList;


- (id)initWithModule:(HO_MODULE_TYPE)type;
- (NSString *)getTrimingCharaFromTextView:(UITextView *)textField;
- (NSString *)getTrimingCharaFromTextField:(UITextField *)textField;
- (NSString *)getTextFromTextField:(UITextField *)textField;

- (HOEditTableViewCell *)tableView:(UITableView *)tableView cellForEditRowAtIndexPath:(NSIndexPath *)indexPath;

#pragma mark
- (void)setNavigationItemTitle:(NSString *)title;
- (void)updateLayout;
- (void)bindController;
- (void)startRequest;

//--no data view
- (void)initNoDataView;
- (void)updateNoResultView:(NSInteger)count;
- (void)showNoDataView:(BOOL)show;

//--tableview
#pragma mark footer of tableview.
- (void)initTableView;
- (void)resetTableViewFrame;
- (void)initTableViewFooterViewWithTitle:(NSString *)title;
- (UIView *)getFooterViewWithTitle:(NSString *)title;
- (void)initTableViewHeaderViewWithTitle:(NSString *)title;
- (void)didClickFooterButton:(UIButton *)btn;
- (void)didClickHeaderButton:(UIButton *)btn;
//--searchView
- (void)initSearchView;
- (void)openSearchView;
- (UITextField *)getInputBox:(NSString *)pleaceHolder;
#pragma mark - picker view --
- (void)initPickerView;
- (void)didPickDone:(id)sender;
- (void)openPickerVIew:(id)sender;
- (void) closePickerView:(id)sender;
- (void) showPickerView:(BOOL)show;
- (void) resetPickerView;
- (void) reloadPickViewData;
//
- (void)handleTapFrom:(UITapGestureRecognizer *)gesture;

- (void)leftButtonItemDidClick;
- (void)rightButtonItemDidClick;
#pragma mark - set tab bar --
- (void)hintDidHide;
- (void)hideHintView;

#pragma mark - loadingView --
- (void)showLoadingView:(BOOL)show;

#pragma mark - keyboard --
- (void) registerKeyboard;
- (void) unregisterKeyboard;

#pragma mark - navigation bar --
- (void) displayLeftButtonItemWithTitle:(NSString *)leftBtnTitle;
- (void) displayRightButtonItemWithTitle:(NSString *)rightBtnTitle;
- (void) displayLeftButtonItemWithImagePath:(NSString *)imagePath;
- (void) displayLeftButtonItemWithButton:(UIButton *)btn;
- (void) displayRightButtonItemWithButton:(UIButton *)btn;
- (void) displayBackButtonItemWithImagePath:(NSString *)imagePath;
- (void) displayRightButtomItemWithTitle:(NSString *)rightBtnTitle;
- (void) displayBackButtonItem;
- (void) registerTapGesture;
- (void) unregisterTapGesture;
- (void) hideBackBtn;
- (void) hideKeyboard;
- (void) goBack;

- (void) hintTimeout:(NSTimer *)timer;
#pragma mark - hint view --
- (void)popupHintView:(NSString *)content;
- (void)popupHintView:(NSString *)content inTime:(double)time;
- (void)popupHintView:(NSString *)content inTime:(double)time needCallback:(BOOL)needCallback;

#pragma mark - keyboard event detect --
- (void)onKeyboardDidShow:(NSNotification *)notification;
- (void)onKeyboardDidHide:(NSNotification *)notification;
- (void)onKeyboardWillShow:(NSNotification *)notification;
- (void)onKeyboardWillHide:(NSNotification *)notification;

- (void)onKeyboardFrameDidChange:(NSNotification *)notification;
- (void)updateSelfViewPosition;
#pragma mark - version check
- (void)checkVersion;
- (void)didReceiveVersion:(HOBaseResponseEntity *)response;
- (void)popupUpdateVersion;


- (void)cleanup;
- (void)requestFailedPromote:(HOBaseResponseEntity *)response;

#pragma mark - tool
- (NSNumber *)numberWithInt:(int)intValue;

-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;

#pragma mark need no network request

- (void)initRequestAgainView;
//

- (void)sendCommand:(NSString *)action data:(id)data;
- (void)sendRequestWithParams:(NSDictionary *)dic;

- (void)requestDidSuccessWithResponse:(HOBaseResponseEntity *)response;
- (void)requestDidFaildWithResponse:(HOBaseResponseEntity *)response;

@end
